﻿namespace C4F.DevKit.Bluetooth.ObjectPushProfile
{
    #region Using Directives
    using System;
    using System.ComponentModel;
    #endregion

 #region BusinessCardPullCompletedEventArgs

    /// <summary>
    /// EventArgs class to be used when a Business Card Pull operation 
    /// completes.
    /// </summary>
    public class BusinessCardPullCompletedEventArgs : AsyncCompletedEventArgs
    {
        #region Private Fields

        /// <summary>
        /// The name of the card that was pulled from the remote device.
        /// </summary>
        private string remoteCardName;

        /// <summary>
        /// The contents of the business card that was pulled from the remote 
        /// device.
        /// </summary>
        private byte[] remoteCardContents;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the name of the card that was pulled from the remote device.
        /// </summary>
        public string RemoteCardName
        {
            get
            {
                RaiseExceptionIfNecessary();
                return this.remoteCardName;
            }
        }

        /// <summary>
        /// Gets the contents of the business card that was pulled from the
        /// remote device.
        /// </summary>
        public byte[] RemoteCardContents
        {
            get
            {
                RaiseExceptionIfNecessary();
                return this.remoteCardContents;
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes the BusinessCardPullCompletedEventArgs object.
        /// </summary>
        /// <param name="remoteCardName">The name of the card that was pulled 
        /// from the remote device.</param>
        /// <param name="remoteCardContents">The byte stream of the card that
        /// was pulled.</param>
        /// <param name="error">An error that occurred during the asynchronous
        /// operation.</param>
        /// <param name="cancelled">A value indicating whether the asynchronous
        /// operation was cancelled.</param>
        /// <param name="userState">The user-supplied state object supplied
        /// when the asynchronous operation was requested.</param>
        /// <exception cref="ArgumentNullException">remoteCardName is passed as
        /// an empty string or a null reference or remoteCardContents is passed
        /// as a null reference.</exception>
        public BusinessCardPullCompletedEventArgs(string remoteCardName,
                byte[] remoteCardContents, Exception error, bool cancelled,
                object userState)
            : base(error, cancelled, userState)
        {
            if (remoteCardName == null)
                throw new ArgumentNullException("remoteCardName");

            if (remoteCardContents == null)
                throw new ArgumentNullException("remoteCardContents");

            this.remoteCardName = remoteCardName;
            this.remoteCardContents = remoteCardContents;
        }

        #endregion
    }
    #endregion

}